-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: Browser will freeze when sync request is intercepted #32925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
|
Hi @alexsch01 👋🏼, thanks for opening this PR! Just to make sure I understand the proposed changes, this would resolve the freezing issue but the |
The routeHandler is executed but the request that goes to the server won't be modified req.headers["foo"] = "bar" The server will not get this since it's not resolved, but anything you console.log in the routeHandler will print in DevTools console |
|
Ok, I see the |
|
The second part of the fix (7b4f2e7) fixes a freezing issue when there's a sync request in cy.origin block The downside is cross-origin cookies most likely won't work in this case In cases where you must use |
|
Thanks for cross origin explanation. I'll have to look into it further. |
|
@alexsch01, I discussed this PR with the rest of the team and we are good with proceeding. We should skip adding the subscriptions entirely here so the |
|
@mschile I skipped adding the subscriptions entirely for sync requests and added the 2 warnings Let me know how that looks |
mschile
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! Made a few changes. Let's go ahead and add some unit and e2e tests.
made some tests, your changes look good |
This issue happens when a synchronous request is intercepted and the
routeHandlerargument to cy.intercept is givenThe second part of this PR (prevent cross origin cookies from breaking sync requests)
Additional details
Steps to test
How has the user experience changed?
PR Tasks
cypress-documentation?type definitions?Note
Detects synchronous XHRs, skips awaiting route handlers and cookie sync that would block, adds XHR patches to flag sync requests, and updates tests/changelog.
req.isSyncRequest(parsed fromx-cypress-is-sync-request) and use it to:cy.intercept()route-handler awaiting for sync XHRs with a warning inintercepted-request.cross:origin:cookies:receivedon sync requests with a warning in response middleware.CypressIncomingRequesttype withisSyncRequest.XMLHttpRequest.opento setx-cypress-is-sync-requestwhenasync=false(both main and cross-origin bundles).patches/cross-origin/*and imports updated.cy.originwith cookie.Written by Cursor Bugbot for commit 39a2fa3. This will update automatically on new commits. Configure here.